validate transformer#671
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR removes step-level ChangesStep-Level Validate Removal and Contract Architecture Shift
New
Scoped Generic Data Attribute Feature
Documentation and Package Dependencies
Sequence Diagram(s)sequenceDiagram
participant CLI
participant validateFlow
participant resolveContracts
participant TransformerValidate
participant cfworkerValidator
participant Ingest
CLI->>validateFlow: validate(flow, { strict? })
validateFlow->>resolveContracts: resolveContracts(flow.contract)
validateFlow->>TransformerValidate: validateEventAgainstContract(event, { contracts, format })
TransformerValidate->>cfworkerValidator: getValidator(schema) / validate(event)
cfworkerValidator-->>TransformerValidate: validation errors[]
TransformerValidate->>Ingest: write errors to ingest at errorsPath
TransformerValidate-->>validateFlow: isValid / errors
validateFlow-->>CLI: report warnings/errors (CONTRACT_VIOLATION if strict)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cli/src/__tests__/unit/validate/flow.test.ts`:
- Line 762: The test fixture uses underscore-style event naming in the 'out'
array (out: ['event', 'page_view']) but the repo requires space-delimited
"entity action" names; update the fixture value from 'page_view' to 'page view'
so the 'out' array becomes ['event', 'page view'] and ensure any assertions or
snapshots referring to that value are updated accordingly.
In `@packages/transformers/validate/src/validate.ts`:
- Around line 31-37: The type-guard isContractRule currently only recognizes a
ContractRule if it has an events object, so Flow.ContractRule values that only
provide a schema are misclassified and cause collectSchemas to push the whole
rule; update isContractRule to accept a rule if it has a valid schema (e.g.,
'schema' in source) or if 'events' exists and is an object, ensuring the
predicate returns true for schema-only rules, and mirror the same change where
the same pattern appears (the similar block around lines 66-76) so
collectSchemas will extract source.schema instead of the entire rule object.
- Around line 25-27: The validator is hardcoded to '2020-12' in getValidator
(cfworker.Validator(mutable, '2020-12')) while event-format.schema.ts declares
draft-07; change getValidator to detect the schema draft from mutable.$schema
when present (map 'http://json-schema.org/draft-07/schema#' to the draft-07
identifier used by cfworker) and pass that draft to cfworker.Validator, falling
back to '2020-12' only if no $schema is present; update the validatorCache usage
accordingly and/or alternatively regenerate eventFormatSchema to use 2020-12
tuple syntax (prefixItems) if you prefer pinning to 2020-12.
In `@website/docs/transformers/validate.mdx`:
- Around line 65-66: Update the paragraph describing the transformer to clarify
that the transformer reads the { ingest, event } context and that each contract
entry enforces required fields while format: true only performs structural/type
validation against the canonical WalkerOS.Event shape (not enforcement of
contract-required fields); revise the sentence that currently implies full
WalkerOS.Event enforcement to explicitly state that required-field checks come
from contract entries (e.g., $contract.<name>) and format: true only validates
shape/types of the canonical partial event and aggregates errors accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f7003bad-02ee-4576-927f-40b17d558e83
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (61)
.changeset/scoped-generic-data-attribute.md.changeset/transformer-validate.mdpackages/cli/examples/flow-complete.jsonpackages/cli/package.jsonpackages/cli/src/__tests__/unit/validate/flow.test.tspackages/cli/src/commands/validate/index.tspackages/cli/src/commands/validate/validators/flow.tspackages/core/src/__tests__/contract.test.tspackages/core/src/__tests__/flow.test.tspackages/core/src/__tests__/schemas/flow-validate-retired.test.tspackages/core/src/__tests__/schemas/validate-flow-config.test.tspackages/core/src/__tests__/step-entry.test.tspackages/core/src/contract.tspackages/core/src/flow.tspackages/core/src/schemas/__tests__/validate-json-schema.test.tspackages/core/src/schemas/flow.tspackages/core/src/schemas/index.tspackages/core/src/schemas/intellisense.tspackages/core/src/schemas/validate-flow-config.tspackages/core/src/step-entry.tspackages/core/src/types/destination.tspackages/core/src/types/flow.tspackages/core/src/types/index.tspackages/core/src/types/source.tspackages/core/src/types/transformer.tspackages/core/src/types/validate.tspackages/mcps/source-browser/src/__tests__/tools/generate.test.tspackages/mcps/source-browser/src/tools/generate.tspackages/transformers/validate/jest.config.mjspackages/transformers/validate/package.jsonpackages/transformers/validate/scripts/generate-format-schema.mjspackages/transformers/validate/src/__tests__/bundle-isolation.test.tspackages/transformers/validate/src/__tests__/format-schema-sync.test.tspackages/transformers/validate/src/__tests__/scaffold.test.tspackages/transformers/validate/src/__tests__/settings.schema.test.tspackages/transformers/validate/src/__tests__/stepExamples.test.tspackages/transformers/validate/src/__tests__/transformer.test.tspackages/transformers/validate/src/__tests__/validate.test.tspackages/transformers/validate/src/dev.tspackages/transformers/validate/src/event-format.schema.tspackages/transformers/validate/src/examples/index.tspackages/transformers/validate/src/examples/step.tspackages/transformers/validate/src/hints.tspackages/transformers/validate/src/index.tspackages/transformers/validate/src/schemas/index.tspackages/transformers/validate/src/schemas/settings.tspackages/transformers/validate/src/transformer.tspackages/transformers/validate/src/types.tspackages/transformers/validate/src/validate.tspackages/transformers/validate/tsconfig.jsonpackages/transformers/validate/tsup.config.tspackages/web/sources/browser/src/__tests__/tagger.test.tspackages/web/sources/browser/src/__tests__/walker.test.tspackages/web/sources/browser/src/tagger.tsskills/walkeros-understanding-flow/SKILL.mdskills/walkeros-understanding-transformers/SKILL.mdwebsite/docs/getting-started/flow/contract.mdxwebsite/docs/getting-started/flow/validate.mdxwebsite/docs/sources/web/browser/tagger.mdxwebsite/docs/transformers/validate.mdxwebsite/sidebars.ts
💤 Files with no reviewable changes (9)
- packages/core/src/step-entry.ts
- packages/core/src/types/destination.ts
- packages/core/src/types/source.ts
- packages/core/src/types/validate.ts
- packages/cli/examples/flow-complete.json
- packages/core/src/types/transformer.ts
- packages/core/src/schemas/index.ts
- packages/core/src/schemas/flow.ts
- packages/core/src/flow.ts
| action: 'view', | ||
| data: { title: 'Home' }, | ||
| }, | ||
| out: ['event', 'page_view'], |
There was a problem hiding this comment.
Use space-delimited event naming in the fixture.
Line 762 uses 'page_view', but this repo requires 'entity action' format with spaces.
Suggested fix
- out: ['event', 'page_view'],
+ out: ['event', 'page view'],As per coding guidelines, **/*.{ts,tsx,js,jsx}: Use event naming format: 'entity action' with space (e.g., 'page view', not 'page_view').
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| out: ['event', 'page_view'], | |
| out: ['event', 'page view'], |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/cli/src/__tests__/unit/validate/flow.test.ts` at line 762, The test
fixture uses underscore-style event naming in the 'out' array (out: ['event',
'page_view']) but the repo requires space-delimited "entity action" names;
update the fixture value from 'page_view' to 'page view' so the 'out' array
becomes ['event', 'page view'] and ensure any assertions or snapshots referring
to that value are updated accordingly.
Source: Coding guidelines
| // Pin draft 2020-12 (the contract authoring draft). | ||
| const validator = new cfworker.Validator(mutable, '2020-12'); | ||
| validatorCache.set(key, validator); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify draft mismatch in current tree (read-only)
rg -n --fixed-strings "new cfworker.Validator" packages/transformers/validate/src/validate.ts
rg -n --fixed-strings "\$schema: 'http://json-schema.org/draft-07/schema#'" packages/transformers/validate/src/event-format.schema.ts
rg -n --fixed-strings "items: [" packages/transformers/validate/src/event-format.schema.tsRepository: elbwalker/walkerOS
Length of output: 231
Fix JSON Schema draft mismatch in validate transformer (draft-07 schema validated as 2020-12).
getValidator hard-pins new cfworker.Validator(mutable, '2020-12'), while event-format.schema.ts declares $schema: 'http://json-schema.org/draft-07/schema#' and uses draft-07 tuple-style items: [...] (e.g., ordered tuple arrays). This can change positional tuple validation semantics (including the format: true validation path). Derive the validator draft from schema.$schema when present, or update/regenerate eventFormatSchema to 2020-12 tuple form (prefixItems).
// Pin draft 2020-12 (the contract authoring draft).
const validator = new cfworker.Validator(mutable, '2020-12');
validatorCache.set(key, validator);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/transformers/validate/src/validate.ts` around lines 25 - 27, The
validator is hardcoded to '2020-12' in getValidator (cfworker.Validator(mutable,
'2020-12')) while event-format.schema.ts declares draft-07; change getValidator
to detect the schema draft from mutable.$schema when present (map
'http://json-schema.org/draft-07/schema#' to the draft-07 identifier used by
cfworker) and pass that draft to cfworker.Validator, falling back to '2020-12'
only if no $schema is present; update the validatorCache usage accordingly
and/or alternatively regenerate eventFormatSchema to use 2020-12 tuple syntax
(prefixItems) if you prefer pinning to 2020-12.
New
@walkeros/transformer-validatetransformer that validates events against JSON Schema contracts. Runs in both web and server flows, supports strict and pass modes, and writes the verdict and error list to configurable paths so you can gate or observe event quality.The declarative per-step
validatefield on sources, transformers, and destinations is removed. Define event shapes in the top-levelcontractand enforce them at runtime by adding atransformer-validatestep that references them via$contract.<name>. Design-time validation now checks step examples against the resolved contract.Summary by CodeRabbit
New Features
Breaking Changes
Documentation